﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using RearLivestock.Beginning.Api.Application.Command.PigBreedings;
using RearLivestock.Common.Dtos;

namespace RearLivestock.Beginning.Api.Controllers
{
    /// <summary>
    /// 种母配种控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PigBreedingsController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public PigBreedingsController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 配种方式显示
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> SearchBreedingmethod(SearchBreedingmethodCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 种母配种添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> AddPigsBreeding(AddPigsBreedingCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 种母配种显示
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result<PageResultDto<PigsBreedingDto>>> SearchPigsBreeding(SearchPigsBreedingCommand cmd)
        {
            return await mediator.Send(cmd);
        }
        /// <summary>
        /// 种母配种删除
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> DeletePigsBreeding(DeletePigsBreedingCommand cmd)
        {
            return await mediator.Send(cmd);
        }
    }
}
